home *** CD-ROM | disk | FTP | other *** search
- (function()
- {
- //appends an element to the tabbar
- this.appendToTabbar = function (anElement)
- {
- var container = this.getElement('appendToTabbar-container')
- if(container)
- {
- if(this.isThereTreeStyleTab() || this.isThereTabKit())//append the container to the bottom
- {
- container.insertBefore(anElement, container.firstChild);
- this.shortChilds(container, 8, true);
- }
- else
- {
- container.appendChild(anElement);
- this.shortChilds(container, 8);
- }
- }
- else
- {
- container = this.create('hbox');
-
- var subcontainer = this.create('vbox');
- subcontainer.setAttribute('id', 'metaTitleDescriptionOnTop-appendToTabbar-container');
-
- subcontainer.appendChild(anElement)
-
- if(this.isThereTreeStyleTab() || this.isThereTabKit())//append the container to the bottom
- {
- var panelcontainer = this.getBrowserElement('status-bar');
- panelcontainer.parentNode.insertBefore(subcontainer, panelcontainer.parentNode.firstChild);
- }
- else
- {
- var panelcontainer = document.getAnonymousElementByAttribute(this.getBrowserElement('content'), "anonid", "panelcontainer");
- panelcontainer.parentNode.insertBefore(subcontainer, panelcontainer.parentNode.lastChild);
- }
- }
- }
- //returns a new element
- this.create = function (elementName)
- {
- return document.createElement(elementName);
- }
- //returns a new text node
- this.createText = function (aString)
- {
- return document.createTextNode(aString);
- }
- //shortcut for document.getElementById
- this.getBrowserElement = function (anID)
- {
- return document.getElementById(anID);
- }
- //return an element of this extension
- this.getElement = function (anID)
- {
- return this.getBrowserElement('metaTitleDescriptionOnTop-'+anID);
- }
- //removes an element from the dom
- this.removeElement = function (anElement)
- {
- if(anElement && anElement.parentNode)//Sometimes the element was removed.
- anElement.parentNode.removeChild(anElement);
- }
- //shorts the childs elements of a node to maxChilds elements
- this.shortChilds = function (anElement, maxChilds, fromTop)
- {
- if(anElement.hasChildNodes())
- {
- var nodesForDeletion = []
- var length = anElement.childNodes.length;
- if(length<=maxChilds)
- return;
- var nodesToRemove = length-maxChilds;
- var nodesRemoved = 0;
-
- if(fromTop)
- {
- for(var a=length-1;a>=0;a--)
- {
- if(!anElement.childNodes[a].hasAttribute('locked'))
- {
- nodesForDeletion[nodesForDeletion.length] = anElement.childNodes[a];
- nodesRemoved++;
- if(nodesRemoved == nodesToRemove)
- break;
- }
- }
- }
- else
- {
- for(var a=0;a<length;a++)
- {
- if(!anElement.childNodes[a].hasAttribute('locked'))
- {
- nodesForDeletion[nodesForDeletion.length] = anElement.childNodes[a];
- nodesRemoved++;
- if(nodesRemoved == nodesToRemove)
- break;
- }
- }
- }
- for(var id in nodesForDeletion)
- anElement.removeChild(nodesForDeletion[id]);
- }
- }
-
- return null;
-
- }).apply(metaTitleDescriptionOnTop);
-